package cn.edu.cjw.APMFP.ui.table;


import cn.edu.cjw.APMFP.BOMTable.pojo.BOMTable;
import cn.edu.cjw.APMFP.RoleRight.pojo.RoleRight;

import javax.swing.table.AbstractTableModel;
import java.util.List;

public class BomTableModel extends AbstractTableModel{

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private List<BOMTable> list;
    private String[] columns = { "编号", "名称", "类型", "单位"};

	public BomTableModel(List<BOMTable> list) {
		super();
		this.list = list;
	}

	@Override
	public int getRowCount() {
		return list.size();
	}

	@Override
	public int getColumnCount() {
		return columns.length;
	}
	
	@Override
	public String getColumnName(int column) {
		return columns[column];
	}
	
	private Object getColumn(BOMTable entity, int n) {
        switch (n) {
            case 0: return entity.getBId();
            case 1: return entity.getBName();
            case 2: return entity.getBtype();
			case 3: return entity.getUnit();
            default: return null;
        }
    }

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return getColumn(list.get(rowIndex), columnIndex);
	}

}
